<?php

class Dashboard extends Controller
{
    
    public function __construct()
    {
        parent::__construct();
        Session::init();
        $logged = Session::get('log_in');
        if($logged === false )
        {
            Session::destroy();
            header('location: ' . URL . 'login');
            exit;
        }
        
        // include js
        $this->view->js = array('dashboard/js/default.js');
    }
    
    
    public function index()
    {
        $this->view->render('dashboard/index');
    }
    
    public function logout()
    {
          Session::destroy();
            header('location: ../login');
            exit;
    }
    
    
    /**
     *  ajax insert in databases
     */
    public function xhrInsert()
    {
       $this->model->xhrInsert();
    }
    
    
    /**
     *  ajax get dataset in the databases
     */
    public function xhrGetListings()
    {
       $this->model->xhrGetListings();
    }
    
    

    /**
     *  ajax get dataset in the databases
     */
    public function xhrDelListing()
    {
       $this->model->xhrDelListing();
    }
    
    
}